#!/usr/bin/env python
#-*- coding:utf-8 -*-

"""
	PROJECT pyevocmm -

	APP     Parla

	MODULE  status

	SITE DESCRIPTION http://code.google.com/p/pyevocomm/ 

	@copyright: 2012 by archetipo <alessio.gerace@gmail.com>
	@license: New BSD License, see COPYING for details.
"""
import data


__all__ = [ 'status' ]

class Status( object ):
	def __init__( self ):
		self.currspeech=''
		self.col=-1
		data.init()
		self.tipo=''
		self.mappa=[]
		self.mappas=[]
		self.mappaa=[]
		
	def init(self):
		self.setlav()
		
	def setmenu(self):
		""" Function doc
	
		@param PARAM: DESCRIPTION
		@return RETURN: DESCRIPTION
		"""
		data.init()
		data.menu()
		self.genmap()
		return 
		
	def setlav(self):
		""" Function doc
	
		@param PARAM: DESCRIPTION
		@return RETURN: DESCRIPTION
		"""
		data.init()
		data.lavoro()
		self.genmap()
		
	def genmap(self):
		self.tipo=data.tipo
		self.mappa=data.mappa
		self.mappaa=data.gruppia
		self.mappas=data.gruppis
		self.mappav=data.gruppiv
		self.reset()
		
	def reset(self):
		self.col=0
		self.line=-1
		self.insel=0
		self.colsel=0
		self.linesel=0
		self.mappas=data.gruppis
		self.currspeech=''
	
	def currcol(self):
		return self.col
		
	def currline(self):
		""" Function doc
		restituisce la posicione corrente del dato selezionato
		@param PARAM: none
		@return RETURN: data
		"""
		return self.mappa[self.col][self.line]
		
	def resetline(self):
		""" Function doc
	
		@param PARAM: DESCRIPTION
		@return RETURN: DESCRIPTION
		"""
		self.mappa[self.col][self.line]=0
	def inselline(self):
		""" Function doc
	
		@param PARAM: DESCRIPTION
		@return RETURN: DESCRIPTION
		"""
		self.mappa[self.col][self.line]=1
	def selline(self):
		""" Function doc
	
		@param PARAM: DESCRIPTION
		@return RETURN: DESCRIPTION
		"""
		self.mappa[self.col][self.line]=2
		self.linesel=1
		
		
	def resetcol(self):
		""" Function doc
	
		@param PARAM: DESCRIPTION
		@return RETURN: DESCRIPTION
		"""
		self.colsel=0
		self.insel=0
		self.linesel=0
	def inselcol(self):
		""" Function doc
	
		@param PARAM: DESCRIPTION
		@return RETURN: DESCRIPTION
		"""
		self.colsel=0
		self.insel=1
		
	def selcol(self):
		""" Function doc
	
		@param PARAM: DESCRIPTION
		@return RETURN: DESCRIPTION
		"""
		self.insel=0
		self.colsel=1
		self.mappas=data.colos
	
	def step_col(self):
		""" Function doc
		gestione della scansione
		
		@param PARAM: None
		@return RETURN: None
		"""
		self.col+=1
		if self.col>(len(self.mappa)-1):self.reset()
		
	def step_line(self):
		""" Function doc
		gestione della scansione
		
		@param PARAM: None
		@return RETURN: None
		"""
		self.line+=1
		if self.line>(len(self.mappa[self.col])-1):
			if self.tipo=='lavoro':
				self.setlav()
			elif self.tipo=='menu':
				self.line=0
			
	def get_currview(self):
		""" Function doc
	
		@param PARAM: DESCRIPTION
		@return RETURN: DESCRIPTION
		"""
		if self.colsel==0:
			return self.mappav[self.col]
		elif self.colsel==1:
			return self.mappav[self.col][self.line]
			
	def get_currspeech(self):
		""" Function doc
	
		@param PARAM: DESCRIPTION
		@return RETURN: DESCRIPTION
		"""
		
		if self.colsel==0:
			if self.col==-1:
				return ''
			else:
				return self.mappas[self.col]
		elif self.colsel==1:
			if self.line==-1:
				return ''
			else:
				return self.mappas[self.col][self.line]
				
	def get_curraction(self):
		""" Function doc
	
		@param PARAM: DESCRIPTION
		@return RETURN: DESCRIPTION
		"""
		
		if self.colsel==0:
			if self.col==-1:
				return ''
			else:
				return self.mappaa[self.col]
		elif self.colsel==1:
			if self.line==-1:
				return ''
			else:
				return self.mappaa[self.col][self.line]




status = Status()


